/**
 * Created by zhangjing on 2018/3/4.
 */
var mongoose=require('mongoose');
var logger=require('../common/logger')
var config=require('../config')

//mongoose 日志打印
if (config.debug){
    var traceMQuery=function (method,info,query) {
        return function (err,result,mills) {
            if (err){
                logger.error('traceMQuery error:', err);
            }
            var infos=[];
            infos.push(query._collection.collection.name+"."+method.blue);
            infos.push(JSON.stringify(info));
            infos.push((mills+"ms").green);
        };
    };
    mongoose.Mongoose.prototype.mquery.setGlobalTraceFunction(traceMQuery);
}